package utils

import (
	"encoding/hex"
	"fmt"
	"strings"
)

func CmdAdd0x(cmd string) string {
	byteArray, err := hex.DecodeString(cmd)
	if err != nil {
		fmt.Println("解码失败:", err)
		return ""
	}

	result := "["
	for i, b := range byteArray {
		if i > 0 {
			result += ", "
		}
		upperByte := strings.ToUpper(fmt.Sprintf("%02x", b))
		result += fmt.Sprintf("0x%s", upperByte)
	}
	result += "]"
	return result
}
